<?php

use think\migration\Migrator;

class AlterCouponConfigIndex extends Migrator
{
    public function up()
    {
        $sql = <<<SQL
        ALTER TABLE `coupon_config` ADD INDEX idx_agentId_configType_status(`agent_id`, `config_type`, `status`) ;
        ALTER TABLE `coupon_config` ADD INDEX idx_agentId_global_status(`agent_id`, `global`, `status`) ;
        ALTER TABLE `coupon_config` ADD INDEX idx_agentId_quoteId_configType_status(`agent_id`, `quote_id`, `config_type`, `status`) ;
SQL;
        $this->execute($sql);
    }

    public function down()
    {
        $sql = <<<SQL
        DROP INDEX idx_agentId_configType_status ON coupon_config ;
        DROP INDEX idx_agentId_global_status ON coupon_config ;
        DROP INDEX idx_agentId_quoteId_configType_status ON coupon_config ;
SQL;
        $this->execute($sql);
    }
}
